/**
 * @param {number[][]} triplets
 * @param {number[]} target
 * @return {boolean}
 */
 var mergeTriplets = function(triplets, target) {
    let [x, y, z] = target
    const ts = triplets.filter(item => {
        return item.includes(x) || item.includes(y) || item.includes(z)
    })
    let t = [0,0,0]
    for(let [xx, yy, zz] of ts){
        if(xx > x || yy > y || zz > z){
            continue
        }
        t[0] = Math.max(t[0], xx)
        t[1] = Math.max(t[1], yy)
        t[2] = Math.max(t[2], zz)
        let [x1, y1, z1] = t
        if(x1 === x && y1 === y && z1 === z){
            return true
        }
    }
    return false
};